<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>分类信息新增</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"> {{include '../shared/_common_top'}}
    <link rel="stylesheet" href="/lib/kindeditor/themes/qq/qq.css" />
    <link rel="stylesheet" href="/lib/kindeditor/plugins/code/prettify.css" />
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">分类信息修改-{{model.title}}</h3>
            </div>
            <div class="panel-body">
                <form method="post" action="/admin/blog/update/{{model.id}}" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">标题</label>
                        <div class="col-sm-10">
                            <!-- 在html5中 通过设置属性required实现必填 -->
                            <input type="text" required class="form-control" name="title" value="{{model.title}}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">分类代码</label>
                        <div class="col-sm-10">
                            <select name="code" class="col-sm-12 form-control">
                                {{each blogType}}
                                <option value="{{$value.name}}">{{$value.name}}</option>
                                {{/each}}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">简介</label>
                        <div class="col-sm-10">
                            <!-- 在html5中 通过设置属性required实现必填 -->
                            <input type="text" required class="form-control" name="jianjie" value="{{model.jianjie}}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">关键词</label>
                        <div class="col-sm-10">
                            <!-- 在html5中 通过设置属性required实现必填 -->
                            <input type="text" required class="form-control" name="crux" value="{{model.crux}}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">详情</label>
                        <div class="col-sm-10">
                            <!-- 在html5中 通过设置属性required实现必填 -->
                            <textarea id="myEditor" name="content" cols="30" rows="10">{{model.content}}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <!-- type="submit" 的按钮点击之后会自动触发表单的提交事件 -->
                            <button type="submit" class="btn btn-primary btn-block">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    {{include '../shared/_common_bottom'}}
    <script>
        $('.panel-body form').validate({
            rules: {
                name: {
                    required: true,
                    minlength: 2
                },
                code: {
                    required: true,
                }
                // code: {
                //     required: true,
                //     remote: '/admin/book_type/validate_code' //远程AJAX验证
                // }
            },
            messages: {
                name: {
                    remote: '分类已存在'
                }
            }
        })
    </script>
    <script charset="utf-8" src="/lib/kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="/lib/kindeditor/lang/zh-CN.js"></script>
    <script charset="utf-8" src="/lib/kindeditor/plugins/code/prettify.js"></script>
    <script type="text/javascript">
        KindEditor.ready(function(K) {
            var editor1 = K.create('#myEditor', {
                // cssPath : '../plugins/code/prettify.css',
                // uploadJson : '../php/upload_json.php',
                // fileManagerJson : '../php/file_manager_json.php',
                allowFileManager: true,
                themeType: "qq",
                width: '700px',
                // themesPath:'lib/kindeditor/themes/',
                afterCreate: function() {
                    var self = this;
                    K.ctrl(document, 13, function() {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                }
            });
            // prettyPrint();
        });
    </script>

</body>

</html>